import { Component } from 'vue';
import { ParamType } from './types';
import BaseParam from './BaseParam.vue';
import TextParam from './TextParam.vue';
import NumberParam from './NumberParam.vue';
import SelectParam from './SelectParam.vue';
import BooleanParam from './BooleanParam.vue';
import SliderParam from './SliderParam.vue';
import ColorParam from './ColorParam.vue';
import ImageParam from './ImageParam.vue';
import ModelParam from './ModelParam.vue';
import TagsParam from './TagsParam.vue';
import CanvasParam from './CanvasParam.vue';
import { QuestionFilled } from '@element-plus/icons-vue';

// 参数组件映射
const paramComponents: Record<ParamType, Component> = {
    [ParamType.Text]: TextParam,
    [ParamType.Number]: NumberParam,
    [ParamType.Select]: SelectParam,
    [ParamType.Boolean]: BooleanParam,
    [ParamType.Slider]: SliderParam,
    [ParamType.Color]: ColorParam,
    [ParamType.Image]: ImageParam,
    [ParamType.Model]: ModelParam,
    [ParamType.Tags]: TagsParam,
    [ParamType.Canvas]: CanvasParam
};

// 获取参数组件
export const getParamComponent = (type: ParamType): Component => {
    return paramComponents[type] || TextParam;
};

// 自动识别节点类型
export const autoDetectParamType = (node: any): ParamType | null => {
    if (!node) return null;

    // 根据节点类型判断参数类型
    switch (node.class_type) {
        case 'CLIPTextEncode':
            return ParamType.Text;
        case 'EmptyLatentImage':
            return ParamType.Number; // 宽高参数
        case 'KSampler':
            return ParamType.Slider;
        case 'CheckpointLoaderSimple':
            return ParamType.Model;
        case 'LoadImage':
            return ParamType.Image;
        default:
            return null;
    }
};

export { ParamType };
export { BaseParam };
export type { ParamConfig } from './types';
export { QuestionFilled };